package com.lmc.edrive.comon;

import java.io.IOException;
import java.util.List;
import java.util.Locale;

import android.content.Context;
import android.location.Address;
import android.location.Geocoder;

public class Utils {

	
	public static String getAddress(Context ctx, double lat, double lng) {
	    Geocoder geocoder = new Geocoder(ctx, Locale.getDefault());
	    try {
	        List<Address> addresses = geocoder.getFromLocation(lat, lng, 1);
	        Address obj = addresses.get(0);
	        String add = obj.getAddressLine(0);
	       
	        add = add + "\n" + obj.getCountryName();
	        add = add + "\n" + obj.getCountryCode();
	        add = add + "\n" + obj.getAdminArea();
	        add = add + "\n" + obj.getPostalCode();
	        add = add + "\n" + obj.getSubAdminArea();
	        add = add + "\n" + obj.getLocality();
	        add = add + "\n" + obj.getSubThoroughfare();

	      return add;
	        // TennisAppActivity.showDialog(add);
	    } catch (IOException e) {
	        // TODO Auto-generated catch block
	      
	    }
	    return null;
	}
}
